home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10650 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: newsfeed.internetmci.com!xmission!inteleNET!usenet
  2. From: langj@jcave.com (Jonathan Lang)
  3. Newsgroups: comp.lang.c++,comp.sys.sgi.misc
  4. Subject: Re: What is the best way to initialize static template members?
  5. Date: Sat, 09 Mar 1996 00:24:47 GMT
  6. Organization: inteleNET Internet Services
  7. Message-ID: <4hqfh0$lid@vodka.intele.net>
  8. References: <313799EF.41C6@mozart.nmrcore.uab.edu> <313AAA8D.41C6@rus.uni-stuttgart.de> <4ho162$io5@vodka.intele.net>
  9. NNTP-Posting-Host: p142.jcave.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. langj@jcave.com (Jonathan Lang) wrote:
  13.  
  14. >Andreas Wierse <wierse@rus.uni-stuttgart.de> wrote:
  15.  
  16. >>Hunter Moseley wrote:
  17. >>> 
  18. >>> What is the best way to initialize static template members?
  19. >>> 
  20. >>> Example:
  21. >>> 
  22. >>> template<class T>
  23. >>> class X
  24. >>>   {
  25. >>>   private :
  26. >>>     static int min_buff_size;
  27. >>>   ...
  28. >>>   };
  29. >>> 
  30. >>> What is the best way to initialize min_buff_size for a given
  31. >>> X<T> class?
  32.  
  33. >>I don't know what's the best way, but I know what works for me :-).
  34.  
  35. >>I maintain a library and all static member initialization takes place
  36. >>in a file named ec_statics.C. One line for example looks like the 
  37. >>following:
  38.  
  39. >>List<MMapEntry> *Malloc_tmp::mmaplist = new List<MMapEntry>;
  40.  
  41. >>Applied to your case this would look like:
  42.  
  43. >>X<T> X::min_buff_size = 100;
  44.  
  45. >>Note, that in my case even the static variable that is initialized 
  46. >>depends on the template.
  47.  
  48. >>I use C++ 4.0 under IRIX 5.3 on my Indigo.
  49.  
  50. >>You can read more about this in the ARM, section 9.4, pp. 179-181.
  51.  
  52. >First, wouldn't this be:
  53.  
  54. >int X<T>::min_buff_size = 100;
  55.  
  56. >?
  57.  
  58. Actually, I think it should be
  59.  
  60. template <class T> int X<T>::min_buff_size = 100;
  61.  
  62. except that it can't be done that way (there are no template objects;
  63. just template classes and template functions); so, how would you do
  64. this?
  65. -- Jonathan Lang (langj@jcave.com)
  66.  
  67.